<template>
<el-dialog
    v-model="dialogVisible"
    :title="dialogObj.title"
    :width="props.width" 
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    :show-close="false"
    align-center
    class="backend-dialog" :class="props.title ? '' : 'backend-dialog-no-title'">
    <div>
        <div>
            <slot></slot>
        </div>
        <div class="text-right mt-30">
            <e-button type="success" @click="close">取消</e-button>
            <e-button :loading="loading" @click="handleConfirm">确认</e-button>
        </div>
    </div>
</el-dialog>
</template>
<script setup>
const dialogVisible = ref(false)
const loading = ref(false)
const dialogObj = ref({})
const paramsObj = ref({})
const acceptParams = (params, dialog = { title: '', width: 529, okText: '确认', cancelText: '取消', okShow: true, cancelShow: true }) => {
    dialogObj.value = dialog;
    paramsObj.value = params;
    dialogVisible.value = true;
}
const emits = defineEmits(['confirm'])
const handleConfirm = () => {
    loading.value = true;
    emits('confirm')
}
const close = () => {
    loading.value = false;
    dialogVisible.value = false;
}
defineExpose({
    acceptParams,
    close
})
</script>

<style lang="scss" scoped>

</style>